home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.9 KB | 215 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMARead.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMAREAD_H
- #define FWMAREAD_H
-
- #ifndef FWTCOLL_H
- #include "FWTColl.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
-
- class FW_CReadableStream;
- class FW_CSuperView;
- class FW_CFrame;
- class FW_MReceiver;
- class FW_CScrollBarScroller;
- class FW_CRadioCluster;
- struct Environment;
- class FW_CMAEventHandler;
- class FW_CMAView;
- class FW_CMAScrollBarScroller;
- class FW_CMAClassCollection;
- class FW_CMAObject;
- class FW_PResourceFile;
- class FW_PFileSpecification;
- class FW_CFont;
- class FW_CColor;
-
- //========================================================================================
- // Types & Constants
- //========================================================================================
-
- // MacApp resource types
- #define FW_kMAType 'View'
- #define FW_kWINDType 'WIND'
-
- // MacApp class signatures, from UMacAppGlobals.h
- const ResType kStdDocument = 'docu';
- const ResType kStdTracker = 'trak';
- const ResType kStdList = 'list';
-
- const ResType kStdButton = 'butn';
- const ResType kStdCheckBox = 'chkb';
- const ResType kStdCluster = 'clus';
- const ResType kStdControl = 'cntl';
- const ResType kStdDefaultView = 'dflt';
- const ResType kStdDialogBehavior = 'dlgb';
- const ResType kStdDialogView = 'dlog';
- const ResType kStdDialogTEView = 'dtev';
- const ResType kStdDrawingEnvironment = 'drwe';
- const ResType kStdEditText = 'edit';
- const ResType kStdGridView = 'grid';
- const ResType kStdIcon = 'icon';
- const ResType kStdIncludeAt = 'inc@';
- const ResType kStdNumberText = 'nmbr';
- const ResType kStdPattern = 'patn';
- const ResType kStdPicture = 'pict';
- const ResType kStdPopup = 'popp';
- const ResType kStdRadio = 'radb';
- const ResType kStdScroller = 'scrl';
- const ResType kStdScrollBar = 'sbar';
- const ResType kStdScrollerScrollBar = 'ssbr';
- const ResType kStdSmallIcon = 'sicn';
- const ResType kStdStaticText = 'stat';
- const ResType kStdTabTEView = 'ttev';
- const ResType kStdTEView = 'tevw';
- const ResType kStdTextGridView = 'txtg';
- const ResType kStdTextListView = 'lstg';
- const ResType kStdView = 'view';
- const ResType kStdWindow = 'wind';
- const ResType kStdTargetBorderView = 'tbor';
-
- const ResType kNullSignature = ' ';
-
- typedef FW_CMAObject* (*MAClassCreatorFunc)(ResType);
-
- #pragma options align=mac68k
-
- typedef struct MAClassTable {
- ResType classID;
- MAClassCreatorFunc creatorFunc;
- } MAClassTable, *MAClassTableP, **MAClassTableH;
-
- #pragma options align=reset
-
- // New ODF error (to move later to FWErrors.h). Also defined in FWPPobRead.h
- #ifndef FW_xWrongViewResourceVersion
- #define FW_xWrongViewResourceVersion -30215
- #endif
-
- // Macro
- #define MACAPP_WARNING(str) if(FW_CMacAppReader::gUseDebugWarnings) FW_DEBUG_MESSAGE(str)
-
- //========================================================================================
- // class FW_CMacAppReader
- //========================================================================================
-
- class FW_CMacAppReader {
- public:
- enum ENextObjectType { kView, kBehavior, kDrawingEnv, kAdorner };
- enum EResourceFileKind { kPartOnly, kPartOrAskUser, kCurrentResFile, kNewResFile };
- enum EErrorKind { kNoError, kNoViewResource, kStreamReadError, kWrongVersion };
-
- // Class registration
- static void RegisterAllMacAppClasses();
- static void RegisterSignature(ResType classID, MAClassCreatorFunc inCreatorFunc);
- static void RegisterClassName(FW_CString& className, MAClassCreatorFunc creatorFunc);
-
- // Main entry point to load MacApp views
- static FW_PlatformError CreateSubViewsFromMacAppResource(Environment* ev,
- FW_ResourceID resourceID,
- FW_CSuperView* superview,
- FW_MReceiver* receiver,
- EResourceFileKind resFileKind,
- FW_Boolean useDebugWarnings = true);
-
- // Dynamic reloading of views
- static FW_PlatformError ReloadViews(Environment* ev,
- FW_ResourceID resourceID,
- FW_CFrame* frame,
- FW_MReceiver* receiver,
- EResourceFileKind resFileKind,
- FW_Boolean useDebugWarnings = true);
-
- // Utilities
- static FW_PResourceFile* GetResFile(Environment* ev, EResourceFileKind resFileKind);
- static FW_Boolean HasResFile() { return (gCurResFileSpec != 0); } ;
- static void GetResFileName(Environment* ev, FW_CString& name);
- static FW_CString ReadStr255(FW_CReadableStream& stream);
- static void GetTextStyle(short textStyleID, FW_CFont& font, FW_CColor& color);
-
- // For internal use
- protected:
- static void ReadStreamObject(Environment* ev,
- FW_CReadableStream& inStream,
- FW_CSuperView* superview,
- FW_MReceiver* receiver,
- ENextObjectType type);
-
- private:
- static FW_CMAObject* ReadStdObject(Environment* ev, FW_CReadableStream& stream, ENextObjectType type);
- static FW_CMAObject* ReadObject(Environment* ev, FW_CReadableStream& stream);
- static short FetchClassIndex(ResType classID);
- static FW_CMAObject* NewBySignature(ResType classID);
- static FW_CMAObject* NewByClassName(FW_CString& className, ResType classID);
- static void PostCreateViewFromStream(Environment* ev, FW_CSuperView* view);
-
- // Class globales
- public:
- static FW_CMAScrollBarScroller* gScroller;
- static FW_CRadioCluster* gCluster;
- static FW_CPoint gOffset;
- static ResType gDefaultButtonID;
- static ResType gCancelButtonID;
-
- private:
- static short gClassCount;
- static MAClassTableH gTableH;
- static FW_CMAClassCollection* gClassCollection;
- static FW_PFileSpecification* gCurResFileSpec;
- static FW_Boolean gUseDebugWarnings;
-
- friend FW_CMAEventHandler;
- friend FW_CMAView;
- };
-
- //========================================================================================
- // class FW_CMacAppClassDesc
- //========================================================================================
-
- class FW_CMAClassDesc {
- public:
- FW_DECLARE_AUTO(FW_CMAClassDesc)
-
- FW_CMAClassDesc(FW_CString& className, MAClassCreatorFunc creator) :
- fClassName(className), fClassCreator(creator) { };
- ~FW_CMAClassDesc() {};
-
- FW_CString fClassName;
- MAClassCreatorFunc fClassCreator;
- };
-
- //========================================================================================
- // class FW_CMAClassCollection
- //========================================================================================
-
- class FW_CMAClassCollection : public FW_TOrderedCollection<FW_CMAClassDesc>
- {
- public:
- FW_DECLARE_AUTO(FW_CMAClassCollection)
-
- FW_CMAClassCollection() : FW_TOrderedCollection<FW_CMAClassDesc>(){}
- ~FW_CMAClassCollection() {}
- };
-
-
- #endif
-